import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 维保商档案信息 */
export interface MaintenanceInformation {
  id: number // ID
  enterpriseName?: string // 企业名称
  simpleName?: string // 简称
  creditCode?: string // 信用代码
  enterpriseCode?: string // 企业代号
  legalRepresentative?: string // 法人代表
  companyWebsite?: string // 公司官网
  contactPerson?: string // 联系人
  mobilePhone?: string // 联系电话
  landlinePhone?: string // 固定电话
  faxNumber?: string // 传真号码
  email?: string // 企业邮箱
  entryDate: string | Dayjs // 入选时间
  status: number // 状态
  bankName?: string // 开户行
  bankAccount?: string // 账号
  taxNumber?: string // 税号
  invoiceTitle?: string // 发票抬头
  registeredAddress?: string // 注册地址
  companyAddress?: string // 公司地址
  businessScope: string // 经营范围
  enterpriseInformation: string // 企业信息
}

// 维保商档案 API
export const MaintenanceInformationApi = {
  // 查询维保商档案分页
  getMaintenanceInformationPage: async (params: any) => {
    return await request.get({ url: `/business/maintenance-information/page`, params })
  },

  // 查询维保商档案详情
  getMaintenanceInformation: async (id: number) => {
    return await request.get({ url: `/business/maintenance-information/get?id=` + id })
  },

  // 新增维保商档案
  createMaintenanceInformation: async (data: MaintenanceInformation) => {
    return await request.post({ url: `/business/maintenance-information/create`, data })
  },

  // 修改维保商档案
  updateMaintenanceInformation: async (data: MaintenanceInformation) => {
    return await request.put({ url: `/business/maintenance-information/update`, data })
  },

  // 删除维保商档案
  deleteMaintenanceInformation: async (id: number) => {
    return await request.delete({ url: `/business/maintenance-information/delete?id=` + id })
  },

  /** 批量删除维保商档案 */
  deleteMaintenanceInformationList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/maintenance-information/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出维保商档案 Excel
  exportMaintenanceInformation: async (params) => {
    return await request.download({ url: `/business/maintenance-information/export-excel`, params })
  },

  // 下载导入模板
  importEqupmentTemplate: async () => {
    return request.download({ url: '/business/maintenance-information/get-import-template' })
  }
}
